#include "string.h"

CHAR* str_copy (CHAR* str1, const CHAR* str2) {
     CHAR* ret = str1;

     while ((*str1++) = (*str2++)) {};

     return ret;
}

CHAR* str_concat (CHAR* str1, const CHAR* str2) {
     CHAR* ret = str1;

     while (*str1) {
           str1++;
     }
     str_copy (str1, str2);

     return ret;
}

SINT16 str_comp (const CHAR* str1, const CHAR* str2) {
	SINT16 ret;

	while (*str1 && *str2) {
		ret = *str1++ - *str2++;
		if (ret != 0) {
			return ret;
		}
	}
	ret = *str1 - *str2;
	return ret;
}

UINT32 str_length (const CHAR* str) {
    UINT32 size = 0;

	if (str == NULL) {
		/* invalid string */
		return RTX_ERROR;
	}

	while (*str++) {
        ++size;
    }

    return size;
}

/*

CHAR* int_to_string(int num)
{
	int i=0;
	int j=0;
	int k=0;
	int ones=0;
	char temp[5]; //5=num digits in 32676
	char ans[5];

	if(num == 0) {
		temp[i] = (char)(48);
		i++;
	} else {
		while (num!=0)
		{
			ones=num%10; //get current ones digit
			temp[i]=(char)(ones+48); //48=(int)'0';
			num=num/10; //remove current ones digit
			i++; //length of number
		}
	}

	for(j=i-1;j>=0;j--)
	{
		ans[k]=temp[j]; //reorder string correctly
		k++;
	}

	ans[i]='\0'; //add null char for end of string

	return (char*)ans;
}

UINT32 char_to_int(CHAR* str)
{
	int value;
	value = (int)(str - 0x30);
	return value;
}
*/
